package xyz.xtt.equity.client;

import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import jakarta.validation.Valid;
import xyz.xtt.asset.client.response.AssetAllInfoResponse;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.equity.api.dto.GetBenefitPurchaseRecordRequest;
import xyz.xtt.equity.api.dto.GetOnSaleBenefitPackageRequest;
import xyz.xtt.equity.api.dto.SaveBenefitPurchaseUnPayDto;
import xyz.xtt.equity.api.dto.TblBenefitPackageDto;
import xyz.xtt.equity.api.dto.TblBenefitPurchaseRecordDto;
import xyz.xtt.equity.api.dto.TblUserBenefitByAssetIdDto;
import xyz.xtt.equity.client.request.BlockAssetNoBenefitRequest;
import xyz.xtt.equity.client.request.GetUnPayBenefitPurchaseRecordRequest;
import xyz.xtt.equity.client.request.HandlePayCancelRequest;
import xyz.xtt.equity.client.request.HandlePaySuccessRequest;
import xyz.xtt.equity.client.request.SendAssetNoBenefitRequest;
import xyz.xtt.equity.client.request.SendDeliverResultRequest;
import xyz.xtt.equity.client.request.SendFreeBenefitPackageRequest;
import xyz.xtt.equity.client.request.TblUserBenefitDto;
import xyz.xtt.equity.client.request.UnBlockAssetNoBenefitRequest;
import xyz.xtt.equity.client.response.AssetEntitlementResponse;

@FeignClient(name = "nft-equity", fallbackFactory = EquityClientFallbackFactory.class)
public interface EquityClient {
	/**
	 * 权益竞换
	 * 
	 * @param deliverRequest
	 * @return
	 */
//	@PostMapping("/api/asset/deliver")
//	public ApiResult<Boolean> deliver(@RequestBody DeliverRequest deliverRequest);

//	@PostMapping("/api/asset/nft/create")
//	public ApiResult<MintResponse> create(@RequestHeader("uid") String uid, @RequestBody @Valid MintRequest mintRequest);
//
//	@PostMapping("/api/asset/nft/mint")
//	public ApiResult<MintResponse> mint(@RequestHeader("uid") String uid, @RequestBody @Valid MintRequest mintRequest);

//	@PostMapping("/api/asset/nft/transferFrom")
//	public ApiResult<TransferFromResponse> transferFrom(@RequestHeader("platform") String platform,
//			@RequestBody @Valid TransferFromRequest transferFromRequest);

//	/**
//	 * 查询待支付订单
//	 * 
//	 * @param fetchRequest
//	 * @return
//	 */
//	@PostMapping("/api/asset/order/fetchUnPaid")
//	ApiResult<List<TblPayOrderDto>> fetchUnPaidOrders(@RequestBody FetchUnPaidOrdersRequest fetchRequest);

//	/**
//	 * 支付订单状态确认
//	 * 
//	 * @param confirmRequest
//	 * @return
//	 */
//	@PostMapping("/api/asset/order/confirmPayStatus")
//	ApiResult<Boolean> confirmPayStatus(@RequestBody @Valid ConfirmPayOrderRequest confirmRequest);

	/**
	 * 获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
//	@PostMapping("/api/asset/order/getPayStatus")
//	ApiResult<Integer> getPayStatus(@RequestBody @NotNull GetPayStatusRequest request);

	/**
	 * 批量获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
//	@PostMapping("/api/asset/order/getPayStatusMap")
//	ApiResult<Map<Long, Integer>> getPayStatusMap(@RequestBody @Valid GetPayStatusMapRequest request);

	/**
	 * 风格使用次数统计
	 * 
	 * @return
	 */
//	@GetMapping("/api/asset/collection/statis")
//	ApiResult<Map<Long, Long>> collectionStatis();

	/**
	 * 玫瑰
	 * 
	 * @return
	 */
//	@GetMapping("/api/asset/rose/statis")
//	ApiResult<Map<Long, Long>> roseStatis();

	/**
	 * 发送小助手消息
	 * 
	 * @param request
	 * @return
	 */
//	@PostMapping("/api/asset/assistant/msg")
//	ApiResult<Boolean> assistantMessage(@RequestBody AssistantMessageRequest request);

//	@GetMapping("/api/asset/order/fetch")
//	ApiResult<TblPayOrderDto> fetchPayOrder(@RequestParam(value = "payOrderId") Long payOrderId);

//	@PostMapping("/api/asset/assetCard/getUserCardInfo")
//	ApiResult<List<TblAssetCardDto>> getUserCardInfo(@RequestBody CardInfoRequest cardInfoRequest);

//	@PostMapping("/api/asset/businessOrder/selectListByGoodsIds")
//	ApiResult<List<BusinessOrderDto>> selectListByGoodsIds(@RequestBody BusinessOrderRequest businessOrderRequest);

//	@PostMapping("/api/asset/businessOrder/getByIds")
//	ApiResult<Map<Long, BusinessOrderDto>> getBusinessListByIds(@RequestBody Set<Long> ids);

//	@RequestMapping("/api/asset/fund/account/getNeedSettleRecords")
//	ApiResult<List<TblUserFundRecordDto>> getNeedSettleRecords(@RequestParam("maxCount") @Positive Integer maxCount,
//			@RequestParam(value = "lastId", required = false) Long lastId);
//
//	@PostMapping("/api/asset/fund/account/updateFundSettled")
//	ApiResult<Boolean> updateFundSettled(@RequestBody @Valid UpdateFundSettledRequest request);

	// 2025/03/19
	/**
	 * 查询资产上的权益
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/equity/entitlement")
	ApiResult<List<AssetEntitlementResponse>> assetEntitlementWithAssetId(@RequestParam("assetId") Long assetId);

	@GetMapping("/api/nft/equity/entitlementDeliver")
	ApiResult<List<Long>> entitlementDeliver(@RequestParam("assetId") Long assetId, @RequestParam("appUid") Long appUid);

	@GetMapping("/api/nft/equity/isVip")
	ApiResult<Boolean> isVip(@RequestParam("appUid") Long appUid);

	@GetMapping("/api/nft/equity/deliverCheck")
	ApiResult<Boolean> deliverCheck(@RequestParam("entitlementId") Long entitlementId, @RequestParam("uid") Long uid);

	@GetMapping("/api/nft/equity/latest")
	ApiResult<TblUserBenefitDto> getLatestUserBenefit(@RequestHeader("uid") String uid, @RequestParam("benefitCode") String benefitCode);

	/**
	 * 获取售卖中的权益包 list<list<int> >
	 * 
	 * @param request 请参数
	 * @return 售卖中的权益包
	 */
	@PostMapping("/api/equity/vip/getOnSaleBenefitPackage")
	ApiResult<TblBenefitPackageDto> getOnSaleBenefitPackage(@RequestBody @Valid GetOnSaleBenefitPackageRequest request);

	@PostMapping("/api/equity/vip/getBenefitPurchaseRecord")
	ApiResult<TblBenefitPurchaseRecordDto> getBenefitPurchaseRecord(@RequestHeader("uid") Long uid,
			@RequestBody @Valid GetBenefitPurchaseRecordRequest request);

	/**
	 * 支付成功处理
	 * 
	 * @param uid
	 * @param request
	 * @return
	 */
	@PostMapping("/api/equity/vip/handlePaySuccess")
	ApiResult<Boolean> handlePaySuccess(@RequestHeader("uid") Long uid, @RequestBody @Valid HandlePaySuccessRequest request);

	/**
	 * 支付取消处理
	 * 
	 * @param uid
	 * @param request
	 * @return
	 */
	@PostMapping("/api/equity/vip/handlePayCancel")
	ApiResult<Boolean> handlePayCancel(@RequestHeader("uid") Long uid, @RequestBody @Valid HandlePayCancelRequest request);

	/**
	 * 查询权益包未支付记录
	 * 
	 * @param uid
	 * @param request
	 * @return
	 */
	@PostMapping("/api/equity/vip/getUnPayBenefitPurchaseRecord")
	ApiResult<TblBenefitPurchaseRecordDto> getUnPayBenefitPurchaseRecord(@RequestHeader("uid") Long uid,
			@RequestBody @Valid GetUnPayBenefitPurchaseRecordRequest request);

	/**
	 * 保存权益包未支付记录
	 * 
	 * @param uid
	 * @param saveDto
	 * @return
	 */
	@PostMapping("/api/equity/vip/saveUnPayBenefitPurchaseRecord")
	ApiResult<Long> saveUnPayBenefitPurchase(@RequestHeader("uid") Long uid, @RequestBody @Valid SaveBenefitPurchaseUnPayDto saveDto);

	@GetMapping("/api/nft/equity/benefitPackageBaseInfo")
	ApiResult<AssetAllInfoResponse> benefitPackageBaseInfo(@RequestParam("benefitPackageId") Long benefitPackageId);

	@GetMapping("/api/nft/equity/getUserBenefits")
	ApiResult<Map<String, Integer>> getUserBenefits(@RequestParam("appUserId") long appUserId, @RequestParam("benefitCodes") String benefitCodes);

	/**
	 * 用户权益消耗
	 * 
	 * @param appUserId
	 * @param benefitCode
	 * @param consumeNum
	 * @param operateBusinessId
	 * @param operateDesc
	 * @return
	 */
	@PostMapping("/api/nft/equity/userBenefitConsumed")
	ApiResult<Boolean> userBenefitConsumed(@RequestParam("appUserId") long appUserId, @RequestParam("benefitCode") String benefitCode,
			@RequestParam("consumeNum") int consumeNum, @RequestParam("operateBusinessId") Long operateBusinessId,
			@RequestParam("operateDesc") String operateDesc);

	/**
	 * 用户权益消耗
	 * 
	 * @param appUserId
	 * @param benefitCode
	 * @param consumeNum
	 * @param operateBusinessId
	 * @param operateDesc
	 * @return 返回实际消耗次数
	 */
	@PostMapping("/api/nft/equity/userBenefitConsumeAsMuchAsPossible")
	ApiResult<Integer> userBenefitConsumeAsMuchAsPossible(@RequestParam("appUserId") long appUserId, @RequestParam("benefitCode") String benefitCode,
			@RequestParam("consumeNum") int consumeNum, @RequestParam("operateBusinessId") Long operateBusinessId,
			@RequestParam("operateDesc") String operateDesc);

	/**
	 * 恢复已消耗用户权益
	 * 
	 * @param appUserId         用户id
	 * @param operateBusinessId 操作业务id。可空。比如铸造审核不通过时恢复权益时传铸造审核记录id
	 * @param operateDesc       操作描述。可空。比如铸造审核不通过恢复权益时传：铸造审核不通过或更具体信息
	 */
	@PostMapping("/api/nft/equity/userBenefitRecover")
	ApiResult<Boolean> userBenefitRecover(@RequestParam("appUserId") long appUserId, @RequestParam("operateBusinessId") Long operateBusinessId,
			@RequestParam("operateDesc") String operateDesc);

	@PostMapping("/api/nft/equity/installByPackageIds")
	ApiResult<Boolean> installByPackageIds(@RequestParam("packageIds") String packageIds, @RequestParam("assetId") Long assetId);

	/**
	 * 赠送免费权益包
	 * 
	 * @param request
	 * @return
	 */
	@PostMapping("/api/nft/equity/sendFreeBenefitPackage")
	ApiResult<Boolean> sendFreeBenefitPackage(@RequestBody @Valid SendFreeBenefitPackageRequest request);

	@PostMapping("/api/nft/equity/sendAssetNoBenefit")
	ApiResult<Boolean> sendAssetNoBenefit(@RequestBody @Valid SendAssetNoBenefitRequest request);

	@GetMapping("/api/nft/equity/getPackageByIds")
	ApiResult<List<TblBenefitPackageDto>> getPackageByIds(@RequestParam List<Long> packageIds);

	@PostMapping("/api/nft/equity/unBlockAssetNoBenefit")
	ApiResult<Boolean> unBlockAssetNoBenefit(@RequestBody UnBlockAssetNoBenefitRequest unBlockAssetNoBenefitRequest);

	@PostMapping("/api/nft/equity/blockAssetNoBenefit")
	ApiResult<Boolean> blockAssetNoBenefit(@RequestBody BlockAssetNoBenefitRequest blockAssetNoBenefitRequest);

	@PostMapping("/api/nft/equity/saveDeliverResult")
	ApiResult<Boolean> saveDeliverResult(@RequestBody SendDeliverResultRequest request);

	@GetMapping("/api/nft/equity/getBenefitDetailInfo")
	ApiResult<TblUserBenefitByAssetIdDto> getBenefitDetailInfo(@RequestHeader("uid") String uid, @RequestParam("assetId") String assetId);
}
